using System;
using System.Runtime.InteropServices;

namespace Leap
{
	public class Arm : Interface
	{
		private HandleRef swigCPtr;

		public float Width => LeapPINVOKE.Arm_Width_get(swigCPtr);

		public Vector Center
		{
			get
			{
				IntPtr intPtr = LeapPINVOKE.Arm_Center_get(swigCPtr);
				return (intPtr == IntPtr.Zero) ? null : new Vector(intPtr, true);
			}
		}

		public Vector Direction
		{
			get
			{
				IntPtr intPtr = LeapPINVOKE.Arm_Direction_get(swigCPtr);
				return (intPtr == IntPtr.Zero) ? null : new Vector(intPtr, true);
			}
		}

		public Matrix Basis
		{
			get
			{
				IntPtr intPtr = LeapPINVOKE.Arm_Basis_get(swigCPtr);
				return (intPtr == IntPtr.Zero) ? null : new Matrix(intPtr, true);
			}
		}

		public Vector ElbowPosition
		{
			get
			{
				IntPtr intPtr = LeapPINVOKE.Arm_ElbowPosition_get(swigCPtr);
				return (intPtr == IntPtr.Zero) ? null : new Vector(intPtr, true);
			}
		}

		public Vector WristPosition
		{
			get
			{
				IntPtr intPtr = LeapPINVOKE.Arm_WristPosition_get(swigCPtr);
				return (intPtr == IntPtr.Zero) ? null : new Vector(intPtr, true);
			}
		}

		public bool IsValid => LeapPINVOKE.Arm_IsValid_get(swigCPtr);

		public static Arm Invalid => new Arm(LeapPINVOKE.Arm_Invalid_get(), false);

		public Arm(IntPtr cPtr, bool cMemoryOwn)
			: base(LeapPINVOKE.Arm_SWIGUpcast(cPtr), cMemoryOwn)
		{
			swigCPtr = new HandleRef(this, cPtr);
		}

		public static HandleRef getCPtr(Arm obj)
		{
			return obj?.swigCPtr ?? new HandleRef(null, IntPtr.Zero);
		}

		~Arm()
		{
			Dispose();
		}

		public override void Dispose()
		{
			lock (this)
			{
				if (swigCPtr.Handle != IntPtr.Zero)
				{
					if (base.swigCMemOwn)
					{
						base.swigCMemOwn = false;
						LeapPINVOKE.delete_Arm(swigCPtr);
					}
					swigCPtr = new HandleRef(null, IntPtr.Zero);
				}
				GC.SuppressFinalize(this);
				base.Dispose();
			}
		}

		public Arm()
			: this(LeapPINVOKE.new_Arm(), true)
		{
		}

		public bool Equals(Arm arg0)
		{
			bool result = LeapPINVOKE.Arm_Equals(swigCPtr, getCPtr(arg0));
			if (LeapPINVOKE.SWIGPendingException.Pending)
			{
				throw LeapPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public override string ToString()
		{
			return LeapPINVOKE.Arm_ToString(swigCPtr);
		}
	}
}
